package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Praise;
import cn.wolfcode.trip.base.service.IPraiseService;
import cn.wolfcode.trip.base.util.JasonResult;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/praises")
@RestController
public class PraiseController {

    @Autowired
    private IPraiseService praiseService;

    /**
     * 新增或删除一条赞的记录
     * 参数：用户的id,被赞的事物的id
     * 资源：/praises
     * 动作：post
     */
    @PostMapping
    public Object saveOrCancel(Praise p){
        JasonResult jr = new JasonResult();
        try {
            jr.setMsg(praiseService.saveOrCancel(p));
        } catch (Exception e) {
            e.printStackTrace();
            jr.mark(e.getMessage());
        }
        return jr ;
    }



}
